package cn.explink.eap.core.metadata.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.explink.eap.core.common.model.json.DataGrid;
import cn.explink.eap.core.metadata.domain.DataType;
import cn.explink.eap.core.metadata.domain.DataTypeEnum;
import cn.explink.eap.core.metadata.domain.Metadata;
import cn.explink.eap.core.metadata.repository.MetadataDAO;

@Service
public class MetadataService {

	@Autowired
	private MetadataDAO metadataDAO = null;

	public void fillMetadata(DataGrid dataGrid) {
		this.getMetadataDAO().fillMetaData(dataGrid);
	}

	public List<Metadata> getAllMetadata() {
		return this.getMetadataDAO().getAllMetaData();
	}

	public List<DataType> getAllDataType() {
		List<DataType> dtList = new ArrayList<DataType>();
		for (DataTypeEnum dt : DataTypeEnum.values()) {
			dtList.add(new DataType(dt.ordinal(), dt.getName()));
		}
		return dtList;
	}

	public MetadataDAO getMetadataDAO() {
		return this.metadataDAO;
	}

}
